﻿<!-- 
 Family Lines code is provided using the Apache License V2.0, January 2004 http://www.apache.org/licenses/
 -->
<!-- A control to show and modify all details regarding a single fact (EVENT in GEDCOM) -->
<UserControl x:Class="KBS.FamilyLines.Controls.FactEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:KBS.FamilyLines" 
             xmlns:Properties="clr-namespace:KBS.FamilyLines.Properties"
             mc:Ignorable="d" 
             d:DesignHeight="300" 
             d:DesignWidth="300">

    <UserControl.Resources>
        <ResourceDictionary>
            <local:NotConverter x:Key="NotConverter"/>
            <local:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>

            <!-- TODO this gives us a header text of the "right" style but the expander button isn't the "right" color -->
            <!-- TODO move to silver/black resources XAML ? -->
            <Style x:Key="MainViewExpander" TargetType="Expander">
                <Setter Property="HeaderTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <TextBlock Text="{Binding}" 
                                           Foreground="{DynamicResource InputFontColor}"                                       
                                           FontFamily="Calibri,Segoe UI"
                                           FontSize="12"
							    />
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>

    </UserControl.Resources>

    <StackPanel>

        <!-- Header -->
        <Border Padding="5,0,5,0" Background="{DynamicResource BackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" 
                BorderThickness="1,1,1,0" CornerRadius="5,5,0,0" Height="30" MinWidth="300" Width="Auto">
            <Grid>
                <!-- Person name -->
                <TextBlock Text="{Binding Path=PName, Mode=Default, FallbackValue=Current Person}" 
                   Style="{DynamicResource HeaderStyle}" FontWeight="Bold" Height="23.94" 
                   Margin="5,1,10,0" DockPanel.Dock="Left" TextTrimming="CharacterEllipsis" 
                   Foreground="{DynamicResource HeaderFontColor}"/>
                <Button Content="X" x:Name="CloseButton" Click="CloseButton_Click"  Height="15"  
                        HorizontalAlignment="Right" Width="15" Style="{DynamicResource RedButtonStyle}"/>
            </Grid>
        </Border>

        <!-- Content -->
        <Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1,1,1,1">
            <StackPanel Height="500"
                        Background="{DynamicResource InputBackgroundBrush}" 
                        >

                <!-- Fact (Event Type) -->
                <StackPanel Orientation="Horizontal">
                    <Label Content="{x:Static Properties:Resources.Event}" Margin="5,0,5,0"
                           Foreground="{DynamicResource InputFontColor}"
                           />
                    <Label Content="{Binding Path=EventName}"
                       Foreground="{DynamicResource InputFontColor}"
                       />
                </StackPanel>

                <Grid Margin="5">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <!-- Event date: row 0 -->
                    <Label Grid.Row="0" Grid.Column="0" Content="{x:Static Properties:Resources.DateHead}"
                           HorizontalAlignment="Right"
                           Margin="0,5,0,0"
                           VerticalAlignment="Center"
                           Padding="0"
                           Foreground="{DynamicResource InputFontColor}" 
                           />
                    <TextBox Grid.Row="0" 
                             Grid.Column="1" 
                             TextWrapping="NoWrap" 
                             x:Name="DateEditTextBox" 
                             Height="22" 
                             Width="135" 
                             HorizontalAlignment="Left" 
                             Margin="5,5,0,0" 
                             IsEnabled="{Binding Path=IsLocked, Converter={StaticResource NotConverter}, Mode=Default}" 
                             Text="{Binding Path=EventDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" 
                             ToolTip="" 
                             ToolTipOpening="ToolTip_All"
                             />

                    <!-- Place : row 1 -->
                    <Label Grid.Row="1" Grid.Column="0" Content="{x:Static Properties:Resources.Place}"
                           HorizontalAlignment="Right"
                           VerticalAlignment="Center"
                           Padding="0"
                           Margin="0,5,0,0"
                           Foreground="{DynamicResource InputFontColor}" 
                           />

                    <TextBox Grid.Row="1" Grid.Column="1"
                             TextWrapping="NoWrap" 
                             x:Name="PlaceEditTextBox" 
                             Text="{Binding Path=EventPlace, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                             Width="250" 
                             Margin="5,5,0,0" 
                             IsEnabled="{Binding Path=IsLocked, Converter={StaticResource NotConverter}, Mode=Default}" 
                             Height="22" 
                             ToolTip="" 
                             ToolTipOpening="ToolTip_All"/>

                    <!-- Description : row 2 -->
                    <Label Grid.Row="2" Grid.Column="0" Content="{x:Static Properties:Resources.DescHead}"
                           HorizontalAlignment="Right"
                           VerticalAlignment="Center"
                           Padding="0"
                           Margin="0,5,0,0"
                           Foreground="{DynamicResource InputFontColor}" 
                           />
                    <TextBox Grid.Row="2" Grid.Column="1"
                             TextWrapping="NoWrap" 
                             Text="{Binding Path=Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                             Width="250" 
                             Margin="5,5,0,0" 
                             IsEnabled="{Binding Path=IsLocked, Converter={StaticResource NotConverter}, Mode=Default}" 
                             Height="22" 
                             ToolTip="" 
                             ToolTipOpening="ToolTip_All"/>
                </Grid>

                <!-- TODO spread buttons out; use grid? -->
                <StackPanel Margin="10" 
                            Orientation="Horizontal"
                            HorizontalAlignment="Center"
                            >
                    <Button Content="{x:Static Properties:Resources.Notes}"/>
                    <Button Content="{x:Static Properties:Resources.Photos}"/>
                    <Button Content="{x:Static Properties:Resources.Citations}"/>
                </StackPanel>

                <Expander Name="expandCHR" 
                          Style="{StaticResource MainViewExpander}"
                          ExpandDirection="Down" 
                          IsExpanded="False" 
                          Header="More Details">
                    <Grid Margin="5">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <!-- Address -->
                        <Label Grid.Row="0" Grid.Column="0" Content="{x:Static Properties:Resources.Address}"
                           HorizontalAlignment="Right"
                           VerticalAlignment="Center"
                           Padding="0"
                           Margin="0,5,0,0"
                           Foreground="{DynamicResource InputFontColor}" 
                           />
                        <TextBox Grid.Row="0" Grid.Column="1"
                             TextWrapping="NoWrap" 
                             Text="{Binding Path=Address, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                             Width="250" 
                             Margin="5,5,0,0" 
                             IsEnabled="{Binding Path=IsLocked, Converter={StaticResource NotConverter}, Mode=Default}" 
                             Height="22" 
                             ToolTip="" 
                             ToolTipOpening="ToolTip_All"/>
                        <!-- Age -->
                        <Label Grid.Row="1" Grid.Column="0" 
                               Content="{x:Static Properties:Resources.Age}"
                               HorizontalAlignment="Right"
                               VerticalAlignment="Center"
                               Padding="0"
                               Margin="0,5,0,0"
                               Foreground="{DynamicResource InputFontColor}" 
                               />
                        <!-- Cause -->
                        <Label Grid.Row="2" Grid.Column="0" 
                               Content="{x:Static Properties:Resources.Cause}"
                               HorizontalAlignment="Right"
                               VerticalAlignment="Center"
                               Padding="0"
                               Margin="0,5,0,0"
                               Foreground="{DynamicResource InputFontColor}" 
                               />
                        <TextBox Grid.Row="2" Grid.Column="1"
                                 TextWrapping="NoWrap" 
                                 Text="{Binding Path=Cause, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                 Width="250" 
                                 Margin="5,5,0,0" 
                                 IsEnabled="{Binding Path=IsLocked, Converter={StaticResource NotConverter}, Mode=Default}" 
                                 Height="22" 
                                 ToolTip="" 
                                 ToolTipOpening="ToolTip_All"/>
                        <!-- Responsible Agency -->
                        <Label Grid.Row="3" Grid.Column="0" Content="{x:Static Properties:Resources.Agency}"
                           HorizontalAlignment="Right"
                           VerticalAlignment="Center"
                           Padding="0"
                           Margin="0,5,0,0"
                           Foreground="{DynamicResource InputFontColor}" 
                           />
                        <TextBox Grid.Row="3" Grid.Column="1"
                             TextWrapping="NoWrap" 
                             Text="{Binding Path=Agency, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                             Width="250" 
                             Margin="5,5,0,0" 
                             IsEnabled="{Binding Path=IsLocked, Converter={StaticResource NotConverter}, Mode=Default}" 
                             Height="22" 
                             ToolTip="" 
                             ToolTipOpening="ToolTip_All"/>
                        <!-- Certainty -->
                        <Label Grid.Row="4" Grid.Column="0" Content="{x:Static Properties:Resources.Certainty}"
                           HorizontalAlignment="Right"
                           VerticalAlignment="Center"
                           Padding="0"
                           Margin="0,5,0,0"
                           Foreground="{DynamicResource InputFontColor}" 
                           />
                        <!-- Privacy -->
                        <Label Grid.Row="5" Grid.Column="0" Content="{x:Static Properties:Resources.Privacy}"
                           HorizontalAlignment="Right"
                           VerticalAlignment="Center"
                           Padding="0"
                           Margin="0,5,0,0"
                           Foreground="{DynamicResource InputFontColor}" 
                           />
                        <!-- Religious Affiliation -->
                        <Label Grid.Row="6" Grid.Column="0" Content="{x:Static Properties:Resources.Religion}"
                           HorizontalAlignment="Right"
                           VerticalAlignment="Center"
                           Padding="0"
                           Margin="0,5,0,0"
                           Foreground="{DynamicResource InputFontColor}" 
                           />
                        <TextBox Grid.Row="6" Grid.Column="1"
                             TextWrapping="NoWrap" 
                             Text="{Binding Path=Religion, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                             Width="250" 
                             Margin="5,5,0,0" 
                             IsEnabled="{Binding Path=IsLocked, Converter={StaticResource NotConverter}, Mode=Default}" 
                             Height="22" 
                             ToolTip="" 
                             ToolTipOpening="ToolTip_All"/>

                    </Grid>
                </Expander>
            </StackPanel>
        </Border>

        <!-- Footer -->
        <Border Background="{DynamicResource BackgroundBrush}" Height="15" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1,0,1,1" CornerRadius="0,0,5,5"/>

    </StackPanel>

</UserControl>
